package com.fst.dsi.lib.presentation.client.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;

public class PresentationUtility {

	public static List<ColumnConfig> getColmunsConfigs(Collection<String> list) {

		List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
		Iterator<String> iter = list.iterator();
		while (iter.hasNext()) {
			String s = iter.next();
			ColumnConfig column = new ColumnConfig();
			column.setId(s);
			column.setHeader(s);
			column.setWidth(100);
			column.setRowHeader(true);
			configs.add(column);

		}
		return configs;

	}

	public static String splitFieldName(String s) {

		String s2 = s;
		int i = 0;
		char c;
		while (i < s2.length()) {
			c = s2.charAt(i);
			if (Character.isUpperCase(c)) {
				break;
			} else
				i++;

		}
		String prefix = s2.substring(0, i);
		String suffix = s2.substring(i, s2.length() - 1);
		return prefix + "" + suffix;
	}
}
